//
//  TopDetailHeader.m
//  XhlTrip
//
//  Created by dllo on 15/8/25.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "TopDetailHeader.h"
#import "TopicModel.h"
#import "UIImageView+WebCache.h"

@implementation TopDetailHeader

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.mage = [[UIImageView alloc] init];
        [self addSubview:self.mage];
        [_mage release];
        
        self.nameLabel = [[UILabel alloc] init];
        [self.mage addSubview:self.nameLabel];
        [_nameLabel release];
        
        _nameLabel.textColor = [UIColor whiteColor];
        _nameLabel.highlighted = YES;
        _nameLabel.font = [UIFont fontWithName:@"Verdana-BoldItalic" size:22 * Width];
        
        
        self.titleLabel = [[UILabel alloc] init];
        [self.mage addSubview:self.titleLabel];
        [_titleLabel release];
        
        _titleLabel.textColor = [UIColor whiteColor];
        _titleLabel.highlighted = YES;
        _titleLabel.font = [UIFont fontWithName:@"Verdana-BoldItalic" size:17 * Width];
        
        self.mage.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
        self.nameLabel.frame = CGRectMake(20 * Width, self.mage.frame.size.height - 70 * Height, self.frame.size.width - 20 * Width, 30 * Height);
        self.titleLabel.frame = CGRectMake(20 * Width, self.mage.frame.size.height - 40 * Height, self.mage.frame.size.width - 40 * Width, 30 * Height);

        

    }
    return self;
}


- (void)setModel:(TopicModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    _nameLabel.text = model.name;
    _titleLabel.text = model.title;
    [_mage sd_setImageWithURL:model.image_url];
}



- (void)dealloc
{
    [_model release];
    [_nameLabel release];
    [_titleLabel release];
    [_mage release];
    [super dealloc];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
